include('shared.lua')

SWEP.PrintName = "Computer Hacker" // 'Nice' Weapon name (Shown on HUD)	
SWEP.Slot = 2 // Slot in the weapon selection menu
SWEP.SlotPos = 1 // Position in the slot
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true

function SWEP:PrimaryAttack()
	if self.IsCracking then return end
		
	self.Dots = self.Dots or ""
	timer.Create("KeyCrackDots", 0.5, 0, function(wep) 
		if not wep:IsValid() then timer.Destroy("KeyCrackDots") return end
		local len = string.len(wep.Dots)
		local dots = {[0]=".", [1]="..", [2]="...", [3]=""}
		wep.Dots = dots[len]
	end, self)
end

function SWEP:Holster()
	self.IsCracking = false
	timer.Destroy("KeyCrackDots")
	return true
end

function SWEP:Succeed()
	self.IsCracking = false
	timer.Destroy("KeyCrackDots")
end

function SWEP:Fail()
	self.IsCracking = false
	timer.Destroy("KeyCrackDots")
end

function SWEP:Think()
end

function SWEP:SecondaryAttack()
	self:PrimaryAttack()
end

function distance(p1, p2)
	local v = p2 - p1
	return math.floor(math.sqrt( v.x*v.x + v.y*v.y + v.z*v.z ))
end
/*
TODO: Make this only highlight enemy hack stations
function SWEP:DrawHUD()
	for k,v in pairs ( ents.FindByClass("ent_pi_factory_lootrefine") ) do
 
		local Position = ( v:GetPos() + Vector( 0,0,15 ) ):ToScreen()
		local Distance = ""
		 
		if v == Entity() then
				Distance = "" 
			else
				local ent = v:GetLocalPos()
				local ply = LocalPlayer():GetLocalPos()
				Distance = tostring(distance(ent, ply))
				
				teamterm = tonumber(v:GetTeam())
				teamyou = tonumber(LocalPlayer():Team())
		end
		 if(teamterm != teamyou)then
			draw.DrawText("Hack Me!", "TargetIDSmall", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )
			draw.DrawText("Distance: "..Distance, "TargetIDSmall", Position.x, Position.y - 10, Color( 255, 255, 255, 255 ), 1 )
		 end
		
	end
end
*/